template<typename T>
class Ptr
{
public:
	Ptr(T* t) : heldPtr(t) {}

	Ptr(const Ptr& other): heldPtr(other.get()) {}

	template<typename U>
	Ptr(const Ptr<U> &other): heldPtr(other.get()) {}

	T *get() const {
		return heldPtr;
	}
private:
	T *heldPtr;
};

class B {};
class A: public B {};

int main(int argc, char*argv[])
{
	/*
	// doesn't work: "cannot convert ‘double*’ to ‘int*’"
	Ptr<int> pi(new int(5));
	Ptr<double> pd(new double(4l));

	delete pi.get();
	pi = pd;
	delete pi.get();
	*/

	A a;
	B b;
	Ptr<A> pa(&a);
	Ptr<B> pb(&b);
	pb = pb;
	pb = pa;


	return 0;
}